#!/bin/env python 

import matplotlib
matplotlib.use('Agg')
from matplotlib.font_manager import FontProperties
matplotlib.rc('xtick',labelsize='x-large')
matplotlib.rc('ytick',labelsize='x-large')
import sys, re, glob
sys.path.append('/home/ca347/scratch/codes/python/')
from halo_functions import *
from scatter_functions import *
import pylab as p
from pylab import *

## This takes in listofdirs.txt containing a list of textfile locations, legendlabels, and markerstyles.  Outputs are scatter plots of various columns in textfile locations ##

#########CHANGE HERE#############

# ENTROPY - MASS 
fKM500scatter007R500 = { 'saveas':'fKM500scatter007R500', 'xcol':2, 'ycol':4,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{K}(\mathrm{r}=0.07\mathrm{r}_{500})[\mathrm{keV}\ \mathrm{cm}^2]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e0,1e4),'title':'Entropy-Mass','legend_position':'best' }
fKM500scatter01R500 = { 'saveas':'fKM500scatter01R500', 'xcol':2, 'ycol':5,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{K}(\mathrm{r}=0.1\mathrm{r}_{500})[\mathrm{keV}\ \mathrm{cm}^2]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e0,1e4),'title':'Entropy-Mass','legend_position':'best' }
fKM500scatter03R500 = { 'saveas':'fKM500scatter03R500', 'xcol':2, 'ycol':6,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{K}(\mathrm{r}=0.3\mathrm{r}_{500})[\mathrm{keV}\ \mathrm{cm}^2]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e0,1e4),'title':'Entropy-Mass','legend_position':'best' }
fKM500scatter1R500 = { 'saveas':'fKM500scatter1R500', 'xcol':2, 'ycol':7,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{K}(\mathrm{r}=\mathrm{r}_{500})[\mathrm{keV}\ \mathrm{cm}^2]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e0,1e4),'title':'Entropy-Mass','legend_position':'best' }
fKM500scatter2R500 = { 'saveas':'fKM500scatter2R500', 'xcol':2, 'ycol':8,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{K}(\mathrm{r}=\mathrm{r}_{500})[\mathrm{keV}\ \mathrm{cm}^2]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e0,1e4),'title':'Entropy-Mass','legend_position':'best' }
fKM500scatter3R500 = { 'saveas':'fKM500scatter3R500', 'xcol':2, 'ycol':9,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{K}(\mathrm{r}=\mathrm{r}_{500})[\mathrm{keV}\ \mathrm{cm}^2]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e0,1e4),'title':'Entropy-Mass','legend_position':'best' }
fK500M500scatter007R500 = { 'saveas':'fK500M500scatter007R500', 'xcol':2, 'ycol':10,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{K}/\mathrm{K}_{500}(.07\mathrm{r}_{500})$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-2,1e2),'title':'Entropy-Mass','legend_position':'best' }
fK500M500scatter01R500 = { 'saveas':'fK500M500scatter01R500', 'xcol':2, 'ycol':11,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{K}/\mathrm{K}_{500}(.1\mathrm{r}_{500})$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-2,1e2),'title':'Entropy-Mass','legend_position':'best' }
fK500M500scatter03R500 = { 'saveas':'fK500M500scatter03R500', 'xcol':2, 'ycol':12,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{K}/\mathrm{K}_{500}(.3\mathrm{r}_{500})$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-2,1e2),'title':'Entropy-Mass','legend_position':'best' }
fK500M500scatter1R500 = { 'saveas':'fK500M500scatter1R500', 'xcol':2, 'ycol':13,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{K}/\mathrm{K}_{500}(\mathrm{r}_{500})$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-2,1e2),'title':'Entropy-Mass','legend_position':'best' }
fK500M500scatter2R500 = { 'saveas':'fK500M500scatter2R500', 'xcol':2, 'ycol':14,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{K}/\mathrm{K}_{500}(2\mathrm{r}_{500})$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-2,1e2),'title':'Entropy-Mass','legend_position':'best' }
fK500M500scatter3R500 = { 'saveas':'fK500M500scatter3R500', 'xcol':2, 'ycol':15,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{K}/\mathrm{K}_{500}(3\mathrm{r}_{500})$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-2,1e2),'title':'Entropy-Mass','legend_position':'best' }


# PRESSURE - MASS
fPM500scatter007R500 = { 'saveas':'fPM500scatter007R500', 'xcol':2, 'ycol':16,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{P}(\mathrm{r}=0.07\mathrm{r}_{500})[\mathrm{erg}\ \mathrm{cm}^3]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-14,1e-9),'title':'Pressure-Mass','legend_position':'best' }
fPM500scatter01R500 = { 'saveas':'fPM500scatter01R500', 'xcol':2, 'ycol':17,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{P}(\mathrm{r}=0.1\mathrm{r}_{500})[\mathrm{erg}\ \mathrm{cm}^3]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-14,1e-9),'title':'Pressure-Mass','legend_position':'best' }
fPM500scatter03R500 = { 'saveas':'fPM500scatter03R500', 'xcol':2, 'ycol':18,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{P}(\mathrm{r}=0.3\mathrm{r}_{500})[\mathrm{erg}\ \mathrm{cm}^3]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-14,1e-8),'title':'Pressure-Mass','legend_position':'best' }
fPM500scatter1R500 = { 'saveas':'fPM500scatter1R500', 'xcol':2, 'ycol':19,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{P}(\mathrm{r}=\mathrm{r}_{500})[\mathrm{erg}\ \mathrm{cm}^3]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-15,1e-10),'title':'Pressure-Mass','legend_position':'best' }
fPM500scatter2R500 = { 'saveas':'fPM500scatter2R500', 'xcol':2, 'ycol':20,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{P}(\mathrm{r}=\mathrm{r}_{500})[\mathrm{erg}\ \mathrm{cm}^3]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-16,1e-10),'title':'Pressure-Mass','legend_position':'best' }
fPM500scatter3R500 = { 'saveas':'fPM500scatter3R500', 'xcol':2, 'ycol':21,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{P}(\mathrm{r}=\mathrm{r}_{500})[\mathrm{erg}\ \mathrm{cm}^3]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-16,1e-11),'title':'Pressure-Mass','legend_position':'best' }
fP500M500scatter007R500 = { 'saveas':'fP500M500scatter007R500', 'xcol':2, 'ycol':22,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{P}/\mathrm{P}_{500}$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-1,1e2),'title':'Pressure-Mass','legend_position':'best' }
fP500M500scatter01R500 = { 'saveas':'fP500M500scatter01R500', 'xcol':2, 'ycol':23,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{P}/\mathrm{P}_{500}$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-1,1e2),'title':'Pressure-Mass','legend_position':'best' }
fP500M500scatter03R500 = { 'saveas':'fP500M500scatter03R500', 'xcol':2, 'ycol':24,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{P}/\mathrm{P}_{500}$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-2,1e2),'title':'Pressure-Mass','legend_position':'best' }
fP500M500scatter1R500 = { 'saveas':'fP500M500scatter1R500', 'xcol':2, 'ycol':25,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{P}/\mathrm{P}_{500}$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-2,1e2),'title':'Pressure-Mass','legend_position':'best' }
fP500M500scatter2R500 = { 'saveas':'fP500M500scatter2R500', 'xcol':2, 'ycol':26,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{P}/\mathrm{P}_{500}$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-4,1e2),'title':'Pressure-Mass','legend_position':'best' }
fP500M500scatter3R500 = { 'saveas':'fP500M500scatter3R500', 'xcol':2, 'ycol':27,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{P}/\mathrm{P}_{500}$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-3,1e2),'title':'Pressure-Mass','legend_position':'best' }



# TEMPERATURE - MASS
fTM500scatter007R500 = { 'saveas':'fTM500scatter007R500', 'xcol':2, 'ycol':28,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{T}(\mathrm{r}=0.07\mathrm{r}_{500})[\mathrm{K}]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e5,1e9),'title':'Temperature-Mass','legend_position':'best' }
fTM500scatter01R500 = { 'saveas':'fTM500scatter01R500', 'xcol':2, 'ycol':29,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{T}(\mathrm{r}=0.1\mathrm{r}_{500})[\mathrm{K}]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e5,1e9),'title':'Temperature-Mass','legend_position':'best' }
fTM500scatter03R500 = { 'saveas':'fTM500scatter03R500', 'xcol':2, 'ycol':30,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{T}(\mathrm{r}=0.3\mathrm{r}_{500})[\mathrm{K}]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e5,1e9),'title':'Temperature-Mass','legend_position':'best' }
fTM500scatter1R500 = { 'saveas':'fTM500scatter1R500', 'xcol':2, 'ycol':31,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{T}(\mathrm{r}=\mathrm{r}_{500})[\mathrm{K}]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e5,1e9),'title':'Temperature-Mass','legend_position':'best' }
fTM500scatter2R500 = { 'saveas':'fTM500scatter2R500', 'xcol':2, 'ycol':32,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{T}(\mathrm{r}=\mathrm{r}_{500})[\mathrm{K}]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e5,1e9),'title':'Temperature-Mass','legend_position':'best' }
fTM500scatter3R500 = { 'saveas':'fTM500scatter3R500', 'xcol':2, 'ycol':33,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{T}(\mathrm{r}=\mathrm{r}_{500})[\mathrm{K}]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e5,1e9),'title':'Temperature-Mass','legend_position':'best' }
fT500M500scatter007R500 = { 'saveas':'fT500M500scatter007R500', 'xcol':2, 'ycol':34,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{T}/\mathrm{T}_{500}$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-1,1e1),'title':'Temperature-Mass','legend_position':'best' }
fT500M500scatter01R500 = { 'saveas':'fT500M500scatter01R500', 'xcol':2, 'ycol':35,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{T}/\mathrm{T}_{500}$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-1,1e1),'title':'Temperature-Mass','legend_position':'best' }
fT500M500scatter03R500 = { 'saveas':'fT500M500scatter03R500', 'xcol':2, 'ycol':36,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{T}/\mathrm{T}_{500}$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-1,1e1),'title':'Temperature-Mass','legend_position':'best' }
fT500M500scatter1R500 = { 'saveas':'fT500M500scatter1R500', 'xcol':2, 'ycol':37,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{T}/\mathrm{T}_{500}$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-1,1e1),'title':'Temperature-Mass','legend_position':'best' }
fT500M500scatter2R500 = { 'saveas':'fT500M500scatter2R500', 'xcol':2, 'ycol':38,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{T}/\mathrm{T}_{500}$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-1,1e1),'title':'Temperature-Mass','legend_position':'best' }
fT500M500scatter3R500 = { 'saveas':'fT500M500scatter3R500', 'xcol':2, 'ycol':39,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{T}/\mathrm{T}_{500}$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-1,1e1),'title':'Temperature-Mass','legend_position':'best' }



# DENSITY - MASS
frhogM500scatter007R500 = { 'saveas':'frhogM500scatter007R500', 'xcol':2, 'ycol':40,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\\rho_{\mathrm{g}}(\mathrm{r}=0.07\mathrm{r}_{500})[\mathrm{M}_{\odot}/h\ (\mathrm{kpc/h})^{-3}]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':'None','title':'Density-Mass','legend_position':'best' }
frhogM500scatter01R500 = { 'saveas':'frhogM500scatter01R500', 'xcol':2, 'ycol':41,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\\rho_{\mathrm{g}}(\mathrm{r}=0.1\mathrm{r}_{500})[\mathrm{M}_{\odot}/h\ (\mathrm{kpc/h})^{-3}]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e3,1e8),'title':'Density-Mass','legend_position':'best' }
frhogM500scatter03R500 = { 'saveas':'frhogM500scatter03R500', 'xcol':2, 'ycol':42,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\\rho_{\mathrm{g}}(\mathrm{r}=0.3\mathrm{r}_{500})[\mathrm{M}_{\odot}/h\ (\mathrm{kpc/h})^{-3}]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e3,1e7),'title':'Density-Mass','legend_position':'best' }
frhogM500scatter1R500 = { 'saveas':'frhogM500scatter1R500', 'xcol':2, 'ycol':43,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\\rho_{\mathrm{g}}(\mathrm{r}=\mathrm{r}_{500})[\mathrm{M}_{\odot}/h\ (\mathrm{kpc/h})^{-3}]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e2,1e6),'title':'Density-Mass','legend_position':'best' }
frhogM500scatter2R500 = { 'saveas':'frhogM500scatter2R500', 'xcol':2, 'ycol':44,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\\rho_{\mathrm{g}}(\mathrm{r}=\mathrm{r}_{500})[\mathrm{M}_{\odot}/h\ (\mathrm{kpc/h})^{-3}]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e2,1e6),'title':'Density-Mass','legend_position':'best' }
frhogM500scatter3R500 = { 'saveas':'frhogM500scatter3R500', 'xcol':2, 'ycol':45,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\\rho_{\mathrm{g}}(\mathrm{r}=\mathrm{r}_{500})[\mathrm{M}_{\odot}/h\ (\mathrm{kpc/h})^{-3}]$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e2,1e6),'title':'Density-Mass','legend_position':'best' }
fnHM500scatter007R500 = { 'saveas':'fnHM500scatter007R500', 'xcol':2, 'ycol':46,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{n}_\mathrm{H}\ [\mathrm{cm}^{-3}]_{500}$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-5,1e0),'title':'Density-Mass','legend_position':'best' }
fnHM500scatter01R500 = { 'saveas':'fnHM500scatter01R500', 'xcol':2, 'ycol':47,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{n}_\mathrm{H}\ [\mathrm{cm}^{-3}]_{500}$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-5,1e0),'title':'Density-Mass','legend_position':'best' }
fnHM500scatter03R500 = { 'saveas':'fnHM500scatter03R500', 'xcol':2, 'ycol':48,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{n}_\mathrm{H}\ [\mathrm{cm}^{-3}]_{500}$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-5,1e1),'title':'Density-Mass','legend_position':'best' }
fnHM500scatter1R500 = { 'saveas':'fnHM500scatter1R500', 'xcol':2, 'ycol':49,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{n}_\mathrm{H}\ [\mathrm{cm}^{-3}]_{500}$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-5,1e-2),'title':'Density-Mass','legend_position':'best' }
fnHM500scatter2R500 = { 'saveas':'fnHM500scatter2R500', 'xcol':2, 'ycol':50,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{n}_\mathrm{H}\ [\mathrm{cm}^{-3}]_{500}$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-6,1e-2),'title':'Density-Mass','legend_position':'best' }
fnHM500scatter3R500 = { 'saveas':'fnHM500scatter3R500', 'xcol':2, 'ycol':51,'xlabel':'$\mathrm{M}_{500}[\mathrm{M}_{\odot}/\mathrm{h}]$','ylabel':'$\mathrm{n}_\mathrm{H}\ [\mathrm{cm}^{-3}]_{500}$',
                  'xlog':1,'ylog':1,'xlims':(1e12,2e15),'ylims':(1e-6,1e-3),'title':'Density-Mass','legend_position':'best' }



plot_items = [ fTM500scatter007R500,fTM500scatter01R500,fTM500scatter03R500,fTM500scatter1R500,fTM500scatter2R500,fTM500scatter3R500,
               fT500M500scatter007R500,fT500M500scatter01R500,fT500M500scatter03R500,fT500M500scatter1R500, fT500M500scatter2R500, fT500M500scatter3R500, 
               fKM500scatter007R500,fKM500scatter01R500,fKM500scatter03R500,fKM500scatter1R500,fKM500scatter2R500,fKM500scatter3R500,
               fK500M500scatter007R500,fK500M500scatter01R500,fK500M500scatter03R500,fK500M500scatter1R500, fK500M500scatter2R500, fK500M500scatter3R500, 
               fPM500scatter007R500,fPM500scatter01R500,fPM500scatter03R500,fPM500scatter1R500,fPM500scatter2R500,fPM500scatter3R500,
               fP500M500scatter007R500,fP500M500scatter01R500,fP500M500scatter03R500,fP500M500scatter1R500, fP500M500scatter2R500, fP500M500scatter3R500, 
               frhogM500scatter007R500,frhogM500scatter01R500,frhogM500scatter03R500,frhogM500scatter1R500,frhogM500scatter2R500,frhogM500scatter3R500,
               fnHM500scatter007R500,fnHM500scatter01R500,fnHM500scatter03R500,fnHM500scatter1R500,fnHM500scatter2R500, fnHM500scatter3R500  ] 
#################################

class MyLogFormatter(LogFormatter) :

    def __call__(self,x,pos=None) :
        if abs(log10(x)) < 2 :
            return "$%g$" % (x,)
        else :
            return "$10^{%g}$" % (log10(x),)

if len(sys.argv) != 2 :
    print 'Usage: plot.py scatterlist.txt[scatterfileloc, legendlabels, markerstyles]'
    sys.exit(1)

scatterlist = sys.argv[1]

scatterfileloc, legendlabels, markerstyles, png_folder = parse_scatter_input( scatterlist )  
print 'scatterfileloc:', scatterfileloc
print 'legendlabels:', legendlabels
print 'markerstyles:',markerstyles #### markerstyles should be dictionary with marker, color, and s
print 'png_folder:',png_folder

for plot_item in plot_items :
    fig = p.figure( figsize = (7,7) )

    f = fig.add_subplot(111)
    plots = {}
    # Loop over each data set (i.e. NR, CSF, AGN) uniquely separated by legend_labels, which are the keys of the dictionaries
    for legend_label in scatterfileloc.keys() :
        print "Plotting for: "+legend_label
        print scatterfileloc[legend_label]
        xdata, ydata = scatter_out( scatterfileloc[legend_label], plot_item )
        print markerstyles['marker'][legend_label]
        print markerstyles['color'][legend_label]
        print markerstyles['s'][legend_label]
        # print xdata
        # print ydata
        plots[legend_label] = f.scatter( xdata, ydata, marker=markerstyles['marker'][legend_label],
                                         color=markerstyles['color'][legend_label], s=markerstyles['s'][legend_label] )
        del xdata, ydata
    # Specify plot settings
    f.set_xlabel(plot_item['xlabel'],fontsize='xx-large')
    f.set_ylabel(plot_item['ylabel'],fontsize='xx-large')
    if (plot_item['xlog']) :
        f.set_xscale('log')
    if (plot_item['ylog']) :
        f.set_yscale('log')
    if plot_item['xlims'] != 'None' :
        f.set_xlim(plot_item['xlims'])
    if plot_item['ylims'] != 'None' :
        f.set_ylim(plot_item['ylims'])

    if len(plots.keys()[0]) > 2 :
        f.legend([plots[legend_label] for legend_label in plots.keys()],plots.keys(),plot_item['legend_position'],markerscale=2.)
        leg = f.get_legend()
        legtext = leg.get_texts()
        leglines = leg.get_lines()
        setp(legtext,fontsize='large')
        setp(leglines,linewidth=0.5)
        leg.draw_frame(False)

    for tick in f.yaxis.get_major_ticks() :
        tick.label1.set_fontsize('x-large')
    for tick in f.xaxis.get_major_ticks() :
        tick.label1.set_fontsize('x-large')
    for line in f.xaxis.get_ticklines()+f.yaxis.get_ticklines() :
        line.set_markersize(10)
        line.set_markeredgewidth(1.2)

    aexp = png_folder.split('_')[-1]
    f.set_title(plot_item['title']+' '+aexp,fontsize='xx-large')
    f.xaxis.set_major_formatter(MyLogFormatter())
    f.yaxis.set_major_formatter(MyLogFormatter())

    # Save the figure
    fig.savefig( png_folder+'/'+plot_item['saveas'], dpi=100 )
